package all.com.jinyongqunxiax.model.mod.manager;

import java.util.HashMap;
import java.util.Map;

public class ModManager {
    private Map<String, Mod> mods = new HashMap<>();

    private ModManager() {
    }

    public static ModManager shared() {
        return Singleton.shared;
    }

    public Mod get(String path) {
        if (mods.containsKey(path)) {
            return mods.get(path);
        } else {
            Mod mod = new Mod(path);
            mods.put(path, mod);
            return mod;
        }
    }

    public void free(Mod mod) {
        mods.remove(mod.root);
    }

    private static class Singleton {
        static volatile ModManager shared = new ModManager();
    }
}
